package com.s10.ecloud.web.action;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;

import com.opensymphony.xwork2.ActionSupport;
import com.s10.ecloud.web.model.PageModel;
import com.s10.ecloud.web.service.IDeviceService;

public class DeviceAction extends ActionSupport {

	@Resource
	private IDeviceService deviceService;

	@Action(value = "/initDeviceList", results = { @Result(name = "success", location = "/page/ind/deviceListPage.jsp") })
	public String initDriverList() throws Exception {

		this.setPageModel();
		deviceService.getDevicePageModel(this.getPager());// 查询PageMode
		// request.setAttribute("admins", pm); // 设置范围
		return this.SUCCESS;

	}

	private PageModel pager;

	public void setPageModel() {

		if (this.pager == null) {
			this.pager = new PageModel();
		}

		if (this.pager.getMaxPageItems() == 0) {
			this.pager.setMaxPageItems(10);
		}
	}

	/**
	 * @return the page
	 */
	public PageModel getPager() {
		return pager;
	}

	/**
	 * @param page
	 *            the page to set
	 */
	public void setPager(PageModel pager) {
		this.pager = pager;
	}
}
